import {Dialog} from 'element-ui';

export default {
  name: 'ElDialog',
  extends: Dialog,
  props: {
    minimizeAble: {type: Boolean, default: false},    // 是否启动最小化功能
    fullscreenAble: {type: Boolean, default: false}   // 是否启动最大化功能
  },
  data() {
    return {
      isMinimize: false
    }
  },
  watch: {
    visible(val) {
      console.log('------visible-----watch-------')
      if (val) {
        this.closed = false;
        this.$emit('open');
        this.$el.addEventListener('scroll', this.updatePopper);
        this.$nextTick(() => {
          this.$refs.dialog.scrollTop = 0;
        });
        if (this.appendToBody) {
          document.body.appendChild(this.$el);
        }
      } else {
        // this.$el.removeEventListener('scroll', this.updatePopper);
        if (!this.closed) this.$emit('close');
        if (this.destroyOnClose) this.key++;
      }
    }
  },
  methods: {
    // 全屏和正常还原
    fullscreenReset() {
      this.fullscreen = !this.fullscreen;
    },
    // 最小化和最小化还原切换
    minimizeReset() {
      this.isMinimize = !this.isMinimize;
    }
  },
  mounted() {
    console.log('----------mounted-----------------')
  },
  updated() {
    console.log('------------updated--------------')
  }
}
